package system

import (
	"fmt"
	amqp "github.com/rabbitmq/amqp091-go"
	"go.uber.org/zap"
	"process/global"
)

type RabbitMQService struct {}

func (rabbitMQService *RabbitMQService) GetConnection() (conn *amqp.Connection, err error) {
	mqConfig := global.GVA_CONFIG.RabbitMq
	url := fmt.Sprintf("amqp://%s:%s@%s:%d/%s", mqConfig.User, mqConfig.Password, mqConfig.Host, mqConfig.Port, mqConfig.Vhost)
	fmt.Println(url)
	conn, err = amqp.Dial(url)
	if err != nil {
		global.GVA_LOG.Error("rabbitMQ连接失败", zap.Error(err))
	}
	return
}
